#include "Actor.h"

Actor::Actor(TileManager * tim)
{
	
	graphic  =SDL_CreateRGBSurface(SDL_HWSURFACE, 32, 32, 32,
		0x00, 0x00, 0x00, 0x00);
	tm = tim;
	collides=true;
	//tile = tm->getTile(0,0);
	Drawable::x = 0;
	Drawable::y= 0;
	uid =1;
	Drawable::lightEmitted = 3.0;

	Draw::apply_surface(0 , 0 , tm->tileset , graphic ,& tm->images[tm->getIndex(1,9)]);
	
	//vision = 3;
	//man, this is ugly
}







Actor::~Actor(void)
{
}


int tileDistance(std::pair<int,int> start, std::pair<int,int> goal)//assumes you can move diagonally
{
	int startMax = std::max(start.first, start.second);
	int goalMax = std::max(goal.first, goal.second);
	return std::abs(startMax-goalMax);

}

bool compare(std::pair<std::string ,int> i, std::pair<std::string, int> j) {
  return i.second < j.second;
}

std::vector<std::pair<int, int>> Actor::aStar(int x, int y)
{
	//int startX = Drawable::getX();
	//int startY = Drawable::getY();
	//std::pair<int,int> start = *new std::pair<int,int>(startX, startY);
	//std::pair<int,int> goal = *new std::pair<int, int>(x, y);
	//
	//std::pair<int,int>* current ;
	//std::vector<std::pair<int,int>> closedSet = *new std::vector<std::pair<int,int>>(); //set of nodes already evaluated
	//std::vector<std::pair<int,int>> openSet = *new std::vector<std::pair<int,int>>(); //The set of tentative nodes to be evaluated, initially containing the start node
	//openSet.push_back(start);
	//
	//std::vector<std::pair<int,int>> cameFrom = *new std::vector<std::pair<int,int>>();//map of navigated nodes
	//
	//std::map<std::pair<int,int>, int> gScore = * new std::map<std::pair<int,int>, int>();
	//std::map<std::pair<int,int>, int> fScore = * new std::map<std::pair<int,int>, int>();
	//gScore[start] = 0;
	//fScore[start] = 0 + tileDistance(start, goal );

	//while(!openSet.empty())
	//{
	//	*current  = *min_element(fScore.begin(), fScore.end(), compare);
	//	if( *current==goal)
	//	{
	//		//return getPath(came_from, goal);
	//	}
	//	
	//	openSet.erase(std::remove(openSet.begin(), openSet.end(), current), openSet.end());
	//	closedSet.push_back(*current);


	}

 //    g_score[start] := 0    // Cost from start along best known path.
 //    // Estimated total cost from start to goal through y.
 //    f_score[start] := g_score[start] + heuristic_cost_estimate(start, goal)
 //
 //    while openset is not empty
 //        current := the node in openset having the lowest f_score[] value
 //        if current = goal
 //            return reconstruct_path(came_from, goal)
 //
 //        remove current from openset
 //        add current to closedset
 //  XX      for each neighbor in neighbor_nodes(current)
 //            tentative_g_score := g_score[current] + dist_between(current,neighbor)
 //            if neighbor in closedset
 //                if tentative_g_score >= g_score[neighbor]
 //                    continue
 //
 //            if neighbor not in openset or tentative_g_score < g_score[neighbor] 
 //                came_from[neighbor] := current
 //                g_score[neighbor] := tentative_g_score
 //                f_score[neighbor] := g_score[neighbor] + heuristic_cost_estimate(neighbor, goal)
 //                if neighbor not in openset
 //                    add neighbor to openset
 //
 //    return failure
 //
 //function reconstruct_path(came_from, current_node)
 //    if came_from[current_node] in set
 //        p := reconstruct_path(came_from, came_from[current_node])
 //        return (p + current_node)
 //    else
 //        return current_node
//}